package gu;

import java.awt.BorderLayout;
import java.awt.Component;

import javax.swing.JDialog;
import javax.swing.JLabel;


public class progressDialog9 extends JDialog{
	private static final long serialVersionUID = 1L;
	private JLabel msgLB, cntLB;
	
	public progressDialog9(Component parent){
		setModal(true);
		setTitle("Finding Pages...");
		
		cntLB = new JLabel("Processed");
		msgLB = new JLabel();
		add(BorderLayout.NORTH,  cntLB);
		add(BorderLayout.CENTER, msgLB);
		setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
		setSize(500, 75);
		setLocationRelativeTo( parent);
		
		final JDialog a = this;
		Thread t = new Thread(new Runnable() {
	        public void run() {
	        	a.setVisible(true);
	        }
	    });
	    t.start();
	}

	public void SetMessage(String msg, int cnt){
		msgLB.setText(msg);
		cntLB.setText(String.format("Processed %s web pages",cnt));
		try {
			Thread.sleep(30);
        } catch (InterruptedException e) {
        	e.printStackTrace();
        }			
	}
	
	public void close(){
		this.setVisible(false);
	}
}
